package CtrlLayer;
import java.util.ArrayList;
import ModelLayer.Employee;
import ModelLayer.EmployeeContainer;

public class EmployeeController
{

    private EmployeeContainer employeeContainer;

    public EmployeeController()
    {
       employeeContainer = EmployeeContainer.getInstance();
    }

  
    public void createEmployeeObjects(){  
       employeeContainer.addEmployee(new Employee(1,"Mike", "asd@asd.sd", "123123123123", "DIY", "asd"));
       employeeContainer.addEmployee(new Employee(2,"Jason",  "asd@asd.sd", "123213123", "DIY", "asd"));
       employeeContainer.addEmployee(new Employee(3,"Peter",  "asd@asd.sd", "123123123", "Timber", "asd"));
    }

        
    public boolean createEmployee(int id, String name, String email,String phoneNumber, String department, String password){
        boolean added = false;
        if(findEmployee(id) == null) {
            employeeContainer.addEmployee(new Employee(id, name, email, phoneNumber, department, password));
            added = true;
        } else {
            added = false;
        }
        return added;
    }

    public Employee findEmployee(int id){    
        return  employeeContainer.findEmployeeById(id);
    }

     public void deleteEmployee(int id){
        employeeContainer.deleteEmployee(employeeContainer.findEmployeeById(id));
    }
    
     public void updateEmployee(int id, String name, String email,String phoneNumber, String department, String password){
        Employee p =  employeeContainer.findEmployeeById(id);
        if(p != null){
            p.setName(name);
            p.setEmail(email);
            p.setPhoneNumber(phoneNumber);
            p.setDepartment(department);
            p.setPassword(password);
        }
    }
    
}
